#include <iostream> 
#include <vector>
using namespace std; 

class Observer;

class Subject{
	private:
		int x,y;
		
	public:
		Subject(){
			x=0;
			y=0;
		}
		Subject(int _x,int _y){
			x=_x;
			y=_y;
		}
		void Add(Observer *t){
			v.push_back(t);
		}
		virtual void Notify()=0;/*{
			vector <Observer *>::iterator it;
			for (it=v.begin();it!=v.end();it++)
				(*it)->Update(x,y);
		}*/
		void DataChange (int _x,int _y){
			x=_x;
			y=_y;
			Notify();
		}
};

class Observer{
	private:
		int x,y;
		Subject *s;
	public:
		Observer(Subject *t){
			s=t;
			s->Add(this);
		}
		virtual void Update(int _x,int _y)=0;/*{
			x=_x;
			y=_y;
		}*/
};

class ConcreteSubject:public Subject{
	private:
		vector <Observer *> v;
	public:
		ConcreteSubject(){
		}
};

int main(void){
	Subject *Su=new Subject(3,5);
	Observer *Ob1=new Observer(Su);
	Observer *Ob1=new Observer(Su);
	//Su->Add(Ob1);
	//Su->Add(Ob2);
	Su->DataChange(8,9);
	delete Su;
	delete Ob1;
	delete Ob2; 
	return 0;
}
